package com.ruoyi.system.service;

import com.ruoyi.system.domain.StrategyParameters;
import com.ruoyi.system.mapper.StrategyParametersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.List;

@Service
public class StrategyService {

    @Autowired
    private StrategyParametersMapper repository;

    @Scheduled(cron = "0 0 0 * * ?") // 每天凌晨0点执行
    public void runMacdStrategy() throws IOException {
        List<StrategyParameters> parameters = repository.selectStrategyParametersList(null);
//        for (StrategyParameter param : parameters) {
//            String accountId = param.getAccountId();
//            String product = param.getProduct();
//            int volume = param.getVolume();
//            String strategyName = param.getStrategyName();
//            String kTimes = param.getKTimes();
//
//            // 构建命令行参数
//            String[] args = {
//                    "python",
//                    "/path/to/your/python/script.py",
//                    accountId,
//                    product,
//                    String.valueOf(volume),
//                    strategyName,
//                    kTimes
//            };
//
//            // 执行Python脚本
//            ProcessBuilder processBuilder = new ProcessBuilder(args);
//            Process process = processBuilder.start();
//            try {
//                process.waitFor();
//            } catch (InterruptedException e) {
//
//                e.printStackTrace();
//            }
//        }
    }
}
